ManualActivitySetting = function (editor) {
    this.editor = editor;
    this.setting = this.getCurrentAttributeSetting("Manual");
    this.actPartsSetting = new ActivityParticipantsSetting(editor);
};

mxUtils.extend(ManualActivitySetting, AttributeSetting);

ManualActivitySetting.prototype.actPartsSetting = null;

ManualActivitySetting.prototype.render = function () {
    this.setProcessNodes();
    this.renderBasicAttr();
    this.renderTaskTactics();
    this.renderExtra();
    //this.renderEvents();
    this.renderReturnSetting();
    this.renderCallbacks();
    //this.renderFormSetting();
    this.renderParticipantSet();
    this.renderRuntimeParameters();
    //this.renderTimeoutSetting();
    this.renderMessageNotifySetting();
    // this.overwriteNewRecord();
    //配置表单项
    this.renderFormParticipantsResult();
    //配置任务接口
    //this.renderRoleWithOrg();

    // 初始化listBox
    this.renderListBox();
};


ManualActivitySetting.prototype.update = function () {

    this.updateBasicAtrr();
    this.updateTaskTactics();
    this.updateExtra();
    //this.updateEvents();
    this.updateReturnSetting();
    this.updateCallbacks();
    //this.updateFormSetting();
    this.updateParticipantSet();
    this.updateRuntimeParameters();
    // // this.updateTimeoutSetting();
    this.updateMessageNotifySetting();

    //this.updateRoleWithOrg();
    //配置表单项
    this.updateFormParticipantsResult();
    this.updateAttributeSetting();
};

/**
 * 将当前流程所有节点保存到processNodes下拉框
 */
ManualActivitySetting.prototype.setProcessNodes = function(){
    var activities = this.getAllActivities();
    var allActi = new Array();
    $(activities).each(function () {
        if(this.value.getAttribute("Name")!=$('#basic-0-name').val()){
            var row = {valueField:this.value.getAttribute("Name"),textField:this.value.getAttribute("DisplayName")};
            allActi.push(row);
        }
    });
    $("#processNodes").kendoDropDownList({
        dataTextField: "textField",
        dataValueField: "valueField",
        dataSource: allActi
    });
}

/**
 * 渲染的基本属性设置页面
 */
ManualActivitySetting.prototype.renderBasicAttr = function () {
    var form = this.setting.getAttribute('Form');
    form = (form == null || form == 'null') ? "" : form;
    $('#basic-0-form').val(form);

    $('#basic-0-name').val(this.setting.getAttribute('Name'));
    $('#basic-0-displayName').val(this.setting.getAttribute('DisplayName'));

    var secrecy = this.setting.getAttribute('secrecy');
    if (secrecy == null) secrecy = "false";
    $('#secrecyHide').attr('value', secrecy);

    var approveType = this.setting.getAttribute('approveType');
    approveType = (approveType == null || approveType == 'null') ? "General" : approveType;
    $('#approveTypeHide').val(approveType);

    $('#basic-0-desc').val(this.setting.getAttribute('Description').trim());
};

/**
 * 保存活动基本属性设置
 */
ManualActivitySetting.prototype.updateBasicAtrr = function () {

    // 获取活动属性配置
    var name = $('#basic-0-name').val();
    var displayName = $('#basic-0-displayName').val();
    var secrecy = document.getElementById("secrecy").value;
    var approveType = $('#basic-0-approveType').val();
    var form = $('#basic-0-form').val();
    var description = $('#basic-0-desc').val();
    // 设置基本属性
    var cas = this.setting;
    cas.setAttribute('Name', name);
    cas.setAttribute('DisplayName', displayName);
    cas.setAttribute('secrecy', secrecy);
    cas.setAttribute('approveType', approveType);
    cas.setAttribute('Form', form);
    cas.setAttribute('Description', description);
};

ManualActivitySetting.prototype.renderTaskTactics = function () {
    var taskTacticsRegion = $('#ef_region_taskTactics');
    var handleTypes = $('input', taskTacticsRegion);
    var handleType = this.setting.getAttribute('HandleType');
    handleTypes.each(function () {
        if ($(this).attr("value") == handleType)
            $(this).attr("checked", "checked");
    });
};

ManualActivitySetting.prototype.updateTaskTactics = function () {
    // 获取任务策略属性配置
    var taskTacticsRegion = $('#ef_region_taskTactics');
    var handleTypes = $('input', taskTacticsRegion);
    var handleType = null;
    handleTypes.each(function () {
        if ($(this).is(':checked'))
            handleType = $(this).attr("value");
    });

    // 设置基本属性
    var cas = this.setting;
    cas.setAttribute('IsDeffered', "");
    cas.setAttribute('HandleType', handleType);
};

/**
 * 渲染扩展属性数据表格
 *
 * @return
 */
ManualActivitySetting.prototype.renderExtra = function () {
    var dom = $(this.setting);
    var block = new Array();
    var grid = $("#ef_grid_extraResult").data("kendoGrid");

    function extraResult(Name, Type, Value, Desc) {
        this.Name = Name;
        this.Type = Type;
        this.Value = Value;
        this.Desc = Desc;
    }

    // 加载扩展属性数据
    $(dom).find('Variable').each(function () {
        var row = new extraResult();
        $.each(this.attributes, function (i, attrib) {
            var name = attrib.name;
            var value = attrib.value;
            row[this.name] = this.value;

        });
        block.push(row);
    });
    grid.dataSource.data(block);
};


/**
 * 保存扩展属性设置
 *
 * @return
 */
ManualActivitySetting.prototype.updateExtra = function () {
    var GRIDNAME = "extraResult";
    // 设置扩展属性
    var doc = this.createXmlDocument();
    var actExtraParams = $(this.setting).find('ActivityExtraParameters')[0];
    if (actExtraParams == null) {
        actExtraParams = doc.createElement('ActivityExtraParameters');
        $(this.setting).find('Extras')[0].appendChild(actExtraParams);
    } else
        $(actExtraParams).empty();

    var block = extraResultGrid.getBlockData();
    var variable = null;
    if (block.getRows().length > 0)
        for (var i = 0; i < block.getRows().length; i++) {
            variable = doc.createElement('Variable');
            variable.setAttribute('Name', block.getCell(i, 'Name'));
            variable.setAttribute('Type', block.getCell(i, 'Type'));
            variable.setAttribute('Value', block.getCell(i, 'Value'));
            variable.setAttribute('Desc', block.getCell(i, 'Desc'));
            actExtraParams.appendChild(variable);
        }
};

/**
 * 渲染事件配置数据表格
 * @return
 */
ManualActivitySetting.prototype.renderEvents = function () {

    var dom = $(this.setting);
    var block = new Array();
    var grid = $("#ef_grid_eventsResult").data("kendoGrid");

    function eventsResult(Type, Class, Description) {
        this.Type = Type;
        this.Class = Class;
        this.Description = Description;
    }

    // 加载扩展属性数据
    $(dom).find('Event').each(function () {
        var row = new eventsResult();
        row.Type = this.getAttribute("Type");
        row.Class = $(this).find('EventListener')[0].getAttribute("class");
        row.Description = $(this).find('EventListener')[0].getAttribute("Description");
        block.push(row);
    });
    grid.dataSource.data(block);
};

/**
 * 保存事件配置
 *
 * @return
 */
ManualActivitySetting.prototype.updateEvents = function () {
    var doc = this.createXmlDocument();
    var events = $(this.setting).find('Events')[0];
    if (events == null) {
        events = doc.createElement('Events');
        $(this.setting).find('Extras')[0].appendChild(events);
    } else
        $(events).empty();
    var grid = $("#ef_grid_eventsResult").data("kendoGrid");
    var block = grid.getBlockData();

    if (block.getRows().length > 0)
        for (var i = 0; i < block.getRows().length; i++) {
            var event = doc.createElement('Event');
            event.setAttribute('Type', block.getCell(i, 'Type'));
            var evtListener = doc.createElement('EventListener');
            evtListener.setAttribute('class', block.getCell(i, 'Class'));
            evtListener.setAttribute('Description', block.getCell(i,
                'Description'));
            event.appendChild(evtListener);
            events.appendChild(event);
        }
};

/**
 * 渲染回退配置数据表格
 *
 * @return
 */
ManualActivitySetting.prototype.renderReturnSetting = function () {
    var dom = $(this.setting);

    // 加载回退属性数据
    var returnTactics = $(dom).find('ReturnsActivities');

    var returnScope = null;
    var returnType = null;
    if (returnTactics.length > 0) {
        returnScope = returnTactics[0].getAttribute("Type");
        returnType = returnTactics[0].getAttribute("Enabled");
    }
    if (returnScope == null)
        returnScope = 'Last';
    $("#returnScope").data("kendoDropDownList").value(returnScope);
    var returnTypes = $("input[name='returnType']");
    returnTypes.each(function () {
        if ($(this).attr("value") == returnType)
            $(this).attr("checked", "checked");
    });

    var selectedRows = [];
    $(dom).find('ReturnsActivity').each(function () {
        selectedRows.push(this.getAttribute("Name"));
    });
    var activities = this.getAllActivities();
    var curActivityName = this.setting.getAttribute("Name");

    function eventsResult(Name, DisplayName) {
        this.Name = Name;
        this.DisplayName = DisplayName;
    }

    var block = new Array();
    //加载回退活动信息
    $(activities).each(function () {
        var row = new eventsResult();
        row.Name = this.value.getAttribute("Name");
        row.DisplayName = this.value.getAttribute("DisplayName");
        if (row.Name != curActivityName)
            block.push(row);
    });
    var grid = $("#ef_grid_returnSettingResult").data("kendoGrid");
    grid.dataSource.data(block);

    // 标注是否选中
    if (block.length > 0)
        for (var i = 0; i < block.length; i++) {
            if (selectedRows.length > 0) {
                for (var j = 0; j < selectedRows.length; j++) {
                    if (selectedRows[j] == block[i].Name) {
                        grid.setCheckedRows(i);
                    }
                }
            }
        }
};

/**
 * 渲染回调配置数据表格
 * @return
 */
ManualActivitySetting.prototype.renderCallbacks = function () {

    var dom = $(this.setting);
    var block = new Array();
    var grid = $("#ef_grid_callbacksResult").data("kendoGrid");

    function eventsResult(Type, ServiceId, Description) {
        this.Type = Type;
        this.ServiceId = ServiceId;
        this.Description = Description;
    }

    // 加载扩展属性数据
    $(dom).find('Callback').each(function () {
        var row = new eventsResult();
        row.Type = this.getAttribute("Type");
        row.ServiceId = this.getAttribute("ServiceId");
        row.Description = this.getAttribute("Description");
        block.push(row);
    });
    grid.dataSource.data(block);
};

/**
 * 保存回退设置
 *
 * @return
 */
ManualActivitySetting.prototype.updateReturnSetting = function () {
    var doc = this.createXmlDocument();
    var racts = $(this.setting).find('ReturnsActivities')[0];
    if (racts == null) {
        racts = doc.createElement('ReturnsActivities');
        $(this.setting).find('Extras')[0].appendChild(racts);
    } else
        $(racts).empty();

    // 设置回退策略配置
    var returnScope = $('#returnScope').val();
    var returnTypes = $("input[name='returnType']");
    var returnType = null;
    returnTypes.each(function () {
        if ($(this).is(":checked"))
            returnType = $(this).attr("value");
    });
    racts.setAttribute('Enabled', returnType);
    racts.setAttribute('Type', returnScope);
    // 设置回退范围
    if (returnScope == "Appointed") {
        var grid = $("#ef_grid_returnSettingResult").data("kendoGrid");
        var ractCheckedRows = grid.getCheckedRows();
        if (ractCheckedRows.length > 0) {
            ract = doc.createElement('ReturnsActivity');
            ract.setAttribute('Name', ractCheckedRows[0]['Name']);
            ract.setAttribute('DisplayName', ractCheckedRows[0]['DisplayName']);
            racts.appendChild(ract);
        }
    }
    if (returnScope == "Scope") {
        var grid = $("#ef_grid_returnSettingResult").data("kendoGrid");
        var ractCheckedRows = grid.getCheckedRows();
        if (ractCheckedRows.length > 0)
            for (var i = 0; i < ractCheckedRows.length; i++) {
                ract = doc.createElement('ReturnsActivity');
                ract.setAttribute('Name', ractCheckedRows[i]['Name']);
                ract.setAttribute('DisplayName', ractCheckedRows[i]['DisplayName']);
                racts.appendChild(ract);
            }
    }
};

/**
 * 保存回调配置
 *
 * @return
 */
ManualActivitySetting.prototype.updateCallbacks = function () {
    var doc = this.createXmlDocument();
    var callbacks = $(this.setting).find('Callbacks')[0];
    if (callbacks == null) {
        callbacks = doc.createElement('Callbacks');
        $(this.setting).find('Extras')[0].appendChild(callbacks);
    } else
        $(callbacks).empty();
    var grid = $("#ef_grid_callbacksResult").data("kendoGrid");
    var block = grid.getBlockData();

    if (block.getRows().length > 0)
        for (var i = 0; i < block.getRows().length; i++) {
            var callback = doc.createElement('Callback');
            callback.setAttribute('Type', block.getCell(i, 'Type'));
            callback.setAttribute('ServiceId', block.getCell(i, 'ServiceId'));
            callback.setAttribute('Description', block.getCell(i, 'Description'));
            callbacks.appendChild(callback);
        }
};


/**
 * 渲染参与者数据表格
 *
 * @return
 */
ManualActivitySetting.prototype.renderParticipantSet = function () {
    var dom = $(this.setting);
    //初始化流程指定活动节点经办人下拉框
    var activities = this.getAllActivities();
    var allActi = new Array();
    $(activities).each(function () {
        if(this.value.getAttribute("Name")!=$('#basic-0-name').val()){
            var row = {valueField:this.value.getAttribute("Name"),textField:this.value.getAttribute("Name")+"-"+this.value.getAttribute("DisplayName")};
            allActi.push(row);
        }
    });
    var dataSource = new kendo.data.DataSource({
        data:allActi
    });
    $("#participantActi").data("kendoDropDownList").setDataSource(dataSource);
    //初始化业务指定经办人iframe
    var processKey = this.getCurrentAttributeSetting("process").getAttribute('Name');
    var taskDefKey = this.setting.getAttribute("Name");
    $("#participantSetBizFrame").attr("src", IPLATUI.CONTEXT_PATH+"/web/EWHB19?inqu_status-0-from=PROCESSDEF&inqu_status-0-processKey="+processKey+"&inqu_status-0-taskDefKey="+taskDefKey);
    //参与者策略
    var auTactics = $(dom).find('AppointUsersTactics');
    var psRegion = $('#participantSet');
    var psType = null;
    var psEnable = null;
    if (auTactics.length > 0) {
        psType = auTactics[0].getAttribute("Type");
        psEnable = auTactics[0].getAttribute("Enabled");
    }
    var psEnables = $("input[name='appointUsersEnable']");
    psEnables.each(function () {
        if ($(this).attr("value") == psEnable)
            $(this).attr("checked", "checked");
    });
    if(psEnable=="false"){
        $("#aps").data("kendoDropDownList").enable(false);
    }
    $("#participantSetOrg").hide();
    $("#participantSetActi").hide();
    $("#participantSetBiz").hide();
    if(psEnable=="false")return;
    if (psType == null)
        psType = 'FromOrg';
    //兼容老流程错误定义
    if(psType=="FromActivityExecutor"){
        psType = 'FromOrg';
    }
    $("#aps").data("kendoDropDownList").value(psType);
    if(psType=="FromOrg"){
        $("#participantSetOrg").show();
        function eventsResult(Id, Name, Type) {
            this.Id = Id;
            this.Name = Name;
            this.Type = Type;
        }
        var block = new Array();
        //初始化指定用户
        $(dom).find('ParticipantSet>Participant').each(function () {
            var row = new eventsResult();
            row.Id = this.getAttribute('Id');
            row.Type = this.getAttribute('Type');
            row.Name = this.getAttribute("Name");
            row.Dept = this.getAttribute("Dept");
            row.DeptName = this.getAttribute("DeptName");
            block.push(row);
        });
        var grid = $("#ef_grid_participantSetResult").data("kendoGrid");
        grid.dataSource.data(block);
        //初始化指定岗位
        this.renderRoleWithOrg();
    }else if(psType=="FromActi"){
        $("#participantSetActi").show();
        //初始化指定节点经办人
        var participantActi = $(dom).find('ParticipantActi');
        if(participantActi.length>0){
            $("#participantActi").data("kendoDropDownList").value(participantActi[0].getAttribute("NodeKey"));
        }
    }else if(psType=="FromBiz"){
        $("#participantSetBiz").show();

    }
};


/**
 * 保存参与者配置
 *
 * @return
 */
ManualActivitySetting.prototype.updateParticipantSet = function () {
    var aps = $('#aps').val();
    var apEnable = $("input[name='appointUsersEnable']:checked").val();
    // 设置选人策略配置
    var racts = $(this.setting).find('AppointUsersTactics')[0];
    if (racts == null) {
        var doc = this.createXmlDocument();
        racts = doc.createElement('AppointUsersTactics');
        $(this.setting).find('Extras')[0].appendChild(racts);
    } else
        $(racts).empty();
    racts.setAttribute('Enabled', apEnable);
    racts.setAttribute('Type', aps);
    if(aps=="FromOrg"){
        //保存用户
        var doc = this.createXmlDocument();
        var participantSet = $(this.setting).find('ParticipantSet')[0];
        if (participantSet == null) {
            participantSet = doc.createElement('ParticipantSet');
            $(this.setting).find('Extras')[0].appendChild(participantSet);
        } else
            $(participantSet).empty();

        var grid = $("#ef_grid_participantSetResult").data("kendoGrid");
        var ractCheckedRows = grid.getDataItems();
        var participant = null;
        if (ractCheckedRows.length > 0){
            for (var i = 0; i < ractCheckedRows.length; i++) {
                participant = doc.createElement('Participant');
                participant.setAttribute('Id', ractCheckedRows[i]['Id']);
                participant.setAttribute('Name', ractCheckedRows[i]['Name']);
                //participant.setAttribute('Dept', ractCheckedRows[i]['Dept']);
                //participant.setAttribute('DeptName', ractCheckedRows[i]['DeptName']);
                participant.setAttribute('Type', ractCheckedRows[i]['Type']);
                participantSet.appendChild(participant);
            }
        }
        //保存岗位
        this.updateRoleWithOrg();
    }else if(aps="FromActi"){
        //保存指定活动经办人
        var participantActi = $(this.setting).find('ParticipantActi')[0];
        if (participantActi == null) {
            var doc = this.createXmlDocument();
            participantActi = doc.createElement('ParticipantActi');
            $(this.setting).find('Extras')[0].appendChild(participantActi);
        } else
            $(participantActi).empty();
        participantActi.setAttribute("NodeKey", $("#participantActi").val());
    }



    /*var aps = $('#aps').val();
    var apEnables = $("input[name='appointUsersEnable']");
    var apEnable = null;
    apEnables.each(function() {
        if ($(this).attr("checked"))
            apEnable = $(this).attr("value");
    });
    racts.setAttribute('Enabled', apEnable);
    racts.setAttribute('Type', aps);*/

};

/**
 * 渲染的时间限制设置页面
 */
ManualActivitySetting.prototype.renderRuntimeParameters = function () {
    var dom = $(this.setting);
    var rts = $(dom).find('RuntimeParameters')[0];
    if (rts == null) return;
    var runtimeParameters = rts.getElementsByTagName('RuntimeParameter');
    if (runtimeParameters.length > 0) {
        for (var i = 0; i < runtimeParameters.length; i++) {
            var type = runtimeParameters[i].getAttribute('Type');
            var value = runtimeParameters[i].getAttribute('Value');
            //if (type == 'AutoAuditForAdjoinActEnable') {
            //    if (value == 'true')
             //       $('[name=autoAuditForAdjoinActEnable]').attr("checked", "checked");
            //}
             if(type=='AutoAuditEnable'){
                 $('#autoAuditEnable').val(value);
                 if(value=='true')
                     $('#autoAuditEnable')[0].checked=true;
                 else
                     $('#autoAuditEnable')[0].checked=false;
             }
            //
            // if(type=='TerminateProcessEnable'){
            //     $('#terminateProcessEnable').val(value);
            //     if(value=='true')
            //         $('#terminateProcessEnable')[0].checked=true;
            //     else
            //         $('#terminateProcessEnable')[0].checked=false;
            // }
            //
            // if(type=='UndoTaskEnable'){
            //     $('#undoTaskEnable').val(value);
            //     if(value=='true')
            //         $('#undoTaskEnable')[0].checked=true;
            //     else
            //         $('#undoTaskEnable')[0].checked=false;
            // }
            // if(type=='EndCoTaskAfterProcessEndEnable'){
            //     $('#endCoTaskAfterProcessEndEnable').val(value);
            //     if(value=='true')
            //         $('#endCoTaskAfterProcessEndEnable')[0].checked=true;
            //     else
            //         $('#endCoTaskAfterProcessEndEnable')[0].checked=false;
            // }
        }
    }
};


ManualActivitySetting.prototype.updateRuntimeParameters = function () {
    var doc = this.createXmlDocument();
    var rtps = $(this.setting).find('RuntimeParameters')[0];
    if (rtps == null) {
        rtps = doc.createElement('RuntimeParameters');
        $(this.setting).find('Extras')[0].appendChild(rtps);
    } else
        $(rtps).empty();

     var autoAudit=DomHelper.createElement('RuntimeParameter');
     autoAudit.setAttribute('Type','AutoAuditEnable');
     if($('#autoAuditEnable')[0].checked)
        autoAudit.setAttribute('Value','true');
     else
     	autoAudit.setAttribute('Value','false');
     rtps.appendChild(autoAudit);
/*
    var autoAuditForAdjoinActEnable = DomHelper.createElement('RuntimeParameter');
    autoAuditForAdjoinActEnable.setAttribute('Type', 'AutoAuditForAdjoinActEnable');
    if ($('[name=autoAuditForAdjoinActEnable]').is(':checked'))
        autoAuditForAdjoinActEnable.setAttribute('Value', 'true');
    else
        autoAuditForAdjoinActEnable.setAttribute('Value', 'false');
    rtps.appendChild(autoAuditForAdjoinActEnable);
*/
    // var terminateProcessEnable=DomHelper.createElement('RuntimeParameter');
    // terminateProcessEnable.setAttribute('Type','TerminateProcessEnable');
    // if($('#terminateProcessEnable')[0].checked)
    // terminateProcessEnable.setAttribute('Value','true');
    // else
    // terminateProcessEnable.setAttribute('Value','false');
    // rtps.appendChild(terminateProcessEnable);
    //
    //
    // var undoTaskEnable=DomHelper.createElement('RuntimeParameter');
    // undoTaskEnable.setAttribute('Type','UndoTaskEnable');
    // if($('#undoTaskEnable')[0].checked)
    // undoTaskEnable.setAttribute('Value','true');
    // else
    // undoTaskEnable.setAttribute('Value','false');
    // rtps.appendChild(undoTaskEnable);
    //
    //
    // var endCoTaskAfterProcessEndEnable=DomHelper.createElement('RuntimeParameter');
    // endCoTaskAfterProcessEndEnable.setAttribute('Type','EndCoTaskAfterProcessEndEnable');
    // if($('#endCoTaskAfterProcessEndEnable')[0].checked)
    // endCoTaskAfterProcessEndEnable.setAttribute('Value','true');
    // else
    // endCoTaskAfterProcessEndEnable.setAttribute('Value','false');
    // rtps.appendChild(endCoTaskAfterProcessEndEnable);
};


/**
 * 渲染消息通知
 */
ManualActivitySetting.prototype.renderMessageNotifySetting = function () {
    var dom = $(this.setting);
    var mns = $(dom).find('MessageNotifySetting')[0];
    if (mns == null) return;

    var messageNotifySettingInputs = $('#messageNotifySettingInputs');

    var activityAssignEmailNotify = mns.getAttribute('activityAssignEmailNotify');
    var activityAssignSmsNotify = mns.getAttribute('activityAssignSmsNotify');
    var activityAssignWeChatNotify = mns.getAttribute('activityAssignWeChatNotify');
    var activityAssignMobileNotify = mns.getAttribute('activityAssignMobileNotify');
    var activityAssignImNotify = mns.getAttribute('activityAssignImNotify');
    var activityAssignOCSNotify = mns.getAttribute('activityAssignOCSNotify');


    if (activityAssignEmailNotify == 'true')
        $('[name=activityAssignEmailNotify]').attr("checked", "checked");
    if (activityAssignSmsNotify == 'true')
        $('[name=activityAssignSmsNotify]').attr("checked", "checked");
    if (activityAssignWeChatNotify == 'true')
        $('[name=activityAssignWeChatNotify]').attr("checked", "checked");
    if (activityAssignMobileNotify == 'true')
        $('[name=activityAssignMobileNotify]').attr("checked", "checked");
    if (activityAssignImNotify == 'true')
        $('[name=activityAssignImNotify]').attr("checked", "checked");
    if (activityAssignOCSNotify == 'true')
        $('[name=activityAssignOCSNotify]').attr("checked", "checked");

    var activityEndEmailNotify = mns.getAttribute('activityEndEmailNotify');
    var activityEndSmsNotify = mns.getAttribute('activityEndSmsNotify');
    var activityEndWeChatNotify = mns.getAttribute('activityEndWeChatNotify');
    var activityEndMobileNotify = mns.getAttribute('activityEndMobileNotify');
    var activityEndImNotify = mns.getAttribute('activityEndImNotify');
    var activityEndOCSNotify = mns.getAttribute('activityEndOCSNotify');


    if (activityEndEmailNotify == 'true')
        $('[name=activityEndEmailNotify]').attr("checked", "checked");
    if (activityEndSmsNotify == 'true')
        $('[name=activityEndSmsNotify]').attr("checked", "checked");
    if (activityEndWeChatNotify == 'true')
        $('[name=activityEndWeChatNotify]').attr("checked", "checked");
    if (activityEndMobileNotify == 'true')
        $('[name=activityEndMobileNotify]').attr("checked", "checked")
    if (activityEndImNotify == 'true')
        $('[name=activityEndImNotify]').attr("checked", "checked")
    if (activityEndOCSNotify == 'true')
        $('[name=activityEndOCSNotify]').attr("checked", "checked")
}

/**
 * 保存消息通知配置
 */
ManualActivitySetting.prototype.updateMessageNotifySetting = function () {
    //activity assign
    var activityAssignEmailNotify = $('[name=activityAssignEmailNotify]').is(':checked');
    var activityAssignSmsNotify = $('[name=activityAssignSmsNotify]').is(':checked');
    var activityAssignWeChatNotify = $('[name=activityAssignWeChatNotify]').is(':checked');
    var activityAssignMobileNotify = $('[name=activityAssignMobileNotify]').is(':checked');
    var activityAssignImNotify = $('[name=activityAssignImNotify]').is(':checked');
    var activityAssignOCSNotify = $('[name=activityAssignOCSNotify]').is(':checked');

    //activity end
    var activityEndEmailNotify = $('[name=activityEndEmailNotify]').is(':checked');
    var activityEndSmsNotify = $('[name=activityEndSmsNotify]').is(':checked');
    var activityEndWeChatNotify = $('[name=activityEndWeChatNotify]').is(':checked');
    var activityEndMobileNotify = $('[name=activityEndMobileNotify]').is(':checked');
    var activityEndImNotify = $('[name=activityEndImNotify]').is(':checked');
    var activityEndOCSNotify = $('[name=activityEndOCSNotify]').is(':checked');

    var doc = this.createXmlDocument();
    var messageNotifySetting = $(this.setting).find('MessageNotifySetting')[0];
    if (messageNotifySetting == null) {
        messageNotifySetting = doc.createElement('MessageNotifySetting');
        $(this.setting).find('Extras')[0].appendChild(messageNotifySetting);
    }
    //activity assign
    if (activityAssignEmailNotify)
        messageNotifySetting.setAttribute('activityAssignEmailNotify', 'true');
    else
        messageNotifySetting.setAttribute('activityAssignEmailNotify', 'false');

    if (activityAssignSmsNotify)
        messageNotifySetting.setAttribute('activityAssignSmsNotify', 'true');
    else
        messageNotifySetting.setAttribute('activityAssignSmsNotify', 'false');

    if (activityAssignWeChatNotify)
        messageNotifySetting.setAttribute('activityAssignWeChatNotify', 'true');
    else
        messageNotifySetting.setAttribute('activityAssignWeChatNotify', 'false');

    if (activityAssignMobileNotify)
        messageNotifySetting.setAttribute('activityAssignMobileNotify', 'true');
    else
        messageNotifySetting.setAttribute('activityAssignMobileNotify', 'false');

    if (activityAssignImNotify)
        messageNotifySetting.setAttribute('activityAssignImNotify', 'true');
    else
        messageNotifySetting.setAttribute('activityAssignImNotify', 'false');

    if (activityAssignOCSNotify)
        messageNotifySetting.setAttribute('activityAssignOCSNotify', 'true');
    else
        messageNotifySetting.setAttribute('activityAssignOCSNotify', 'false');

    //activity end
    if (activityEndEmailNotify)
        messageNotifySetting.setAttribute('activityEndEmailNotify', 'true');
    else
        messageNotifySetting.setAttribute('activityEndEmailNotify', 'false');

    if (activityEndSmsNotify)
        messageNotifySetting.setAttribute('activityEndSmsNotify', 'true');
    else
        messageNotifySetting.setAttribute('activityEndSmsNotify', 'false');

    if (activityEndWeChatNotify)
        messageNotifySetting.setAttribute('activityEndWeChatNotify', 'true');
    else
        messageNotifySetting.setAttribute('activityEndWeChatNotify', 'false');

    if (activityEndMobileNotify)
        messageNotifySetting.setAttribute('activityEndMobileNotify', 'true');
    else
        messageNotifySetting.setAttribute('activityEndMobileNotify', 'false');

    if (activityEndImNotify)
        messageNotifySetting.setAttribute('activityEndImNotify', 'true');
    else
        messageNotifySetting.setAttribute('activityEndImNotify', 'false');

    if (activityEndOCSNotify)
        messageNotifySetting.setAttribute('activityEndOCSNotify', 'true');
    else
        messageNotifySetting.setAttribute('activityEndOCSNotify', 'false');

};

/**
 * 渲染的表单配置设置页面
 */
ManualActivitySetting.prototype.renderFormParticipantsResult = function () {
    var dom = $(this.setting);
    var FormConfiguration = $(dom).find('FormConfiguration')[0];
    if (FormConfiguration != null && FormConfiguration != undefined) {
        $('#approveFormUrl').val(FormConfiguration.getAttribute('approveFormUrl'));
        $('#approveFormUrlParameters').val(FormConfiguration.getAttribute('approveFormUrlParameters'));
        $('#viewFormUrl').val(FormConfiguration.getAttribute('viewFormUrl'));
        $('#viewFormUrlParameters').val(FormConfiguration.getAttribute('viewFormUrlParameters'));
        $('#updateFormUrl').val(FormConfiguration.getAttribute('updateFormUrl'));
        $('#updateFormUrlParameters').val(FormConfiguration.getAttribute('updateFormUrlParameters'));

        var Values = $("input[name='integrateFormType']");
        var Value = FormConfiguration.getAttribute('integrateFormType');
        Values.each(function () {
            if ($(this).attr("Value") == Value)
                $(this).attr("checked", "checked");
        });

        var Values = $("input[name='isIntegrateApproveHistory']");
        var Value = FormConfiguration.getAttribute('isIntegrateApproveHistory');
        if (Value == "false") {
            $("#setApproveHistoryFormSourceType").hide();
        } else {
            $("#setApproveHistoryFormSourceType").show();
        }
        Values.each(function () {
            if ($(this).attr("Value") == Value)
                $(this).attr("checked", "checked");
        });

        var Values = $("input[name='approveHistoryFormSourceType']");
        Value = FormConfiguration.getAttribute('approveHistoryFormSourceType');
        if (Value == "false") {
            $("#setApproveHistoryFormUrl").show();
        } else {
            $("#setApproveHistoryFormUrl").hide();
        }
        Values.each(function () {
            if ($(this).attr("Value") == Value)
                $(this).attr("checked", "checked");
        });
        $('#approveHistoryFormUrl').val(FormConfiguration.getAttribute('approveHistoryFormUrl'));
        $('#inqu_status-0-nodeCode').val(FormConfiguration.getAttribute('integrateActivities'));
        $('#inqu_status-0-nodeCode_textField').val(FormConfiguration.getAttribute('integrateActivitiestextField'));
        //通用审批表单处理
        var nextParticipants = $("input[name='nextParticipant']");
        var nextParticipant = FormConfiguration.getAttribute('nextParticipant');
        nextParticipants.each(function () {
            if ($(this).attr("Value") == nextParticipant)
                $(this).attr("checked", "checked");
        });
        if(nextParticipant=="Post"){
            $('#nextParticipantPost').data("kendoDropDownList").value(FormConfiguration.getAttribute('nextParticipantPost'));
            $("#nextParticipantByPost").show();
        }

        var ifNotifys = $("input[name='ifNotify']");
        var ifNotify = FormConfiguration.getAttribute('ifNotify');
        ifNotifys.each(function () {
            if ($(this).attr("Value") == ifNotify)
                $(this).attr("checked", "checked");
        });

        var disEndProcs = $("input[name='disEndProc']");
        var disEndProc = FormConfiguration.getAttribute('disEndProc');
        disEndProcs.each(function () {
            if ($(this).attr("Value") == disEndProc)
                $(this).attr("checked", "checked");
        });

        var requireOpinionDisEndProcs = $("input[name='requireOpinionDisEndProc']");
        var requireOpinionDisEndProc = FormConfiguration.getAttribute('requireOpinionDisEndProc');
        requireOpinionDisEndProcs.each(function () {
            if ($(this).attr("Value") == requireOpinionDisEndProc)
                $(this).attr("checked", "checked");
        });

        var requireOpinionBacks = $("input[name='requireOpinionBack']");
        var requireOpinionBack = FormConfiguration.getAttribute('requireOpinionBack');
        requireOpinionBacks.each(function () {
            if ($(this).attr("Value") == requireOpinionBack)
                $(this).attr("checked", "checked");
        });
    } else {
        $("#setApproveHistoryFormSourceType").hide();
    }
};

/**
 * 保存表单配置
 *
 * @return
 */
ManualActivitySetting.prototype.updateFormParticipantsResult = function () {
    // 设置表单配置
    var doc = this.createXmlDocument();
    var actExtraParams = $(this.setting).find('FormConfiguration')[0];
    if (actExtraParams == null) {
        actExtraParams = doc.createElement('FormConfiguration');
        $(this.setting).find('Extras')[0].appendChild(actExtraParams);
    } else
        $(actExtraParams).empty();

    var approveFormUrl = $('#approveFormUrl').val();
    var approveFormUrlParameters = $('#approveFormUrlParameters').val();
    var viewFormUrl = $('#viewFormUrl').val();
    var viewFormUrlParameters = $('#viewFormUrlParameters').val();
    var updateFormUrl = $('#updateFormUrl').val();
    var updateFormUrlParameters = $('#updateFormUrlParameters').val();
    actExtraParams.setAttribute('approveFormUrl', approveFormUrl);
    actExtraParams.setAttribute('approveFormUrlParameters', approveFormUrlParameters);
    actExtraParams.setAttribute('viewFormUrl', viewFormUrl);
    actExtraParams.setAttribute('viewFormUrlParameters', viewFormUrlParameters);
    actExtraParams.setAttribute('updateFormUrl', updateFormUrl);
    actExtraParams.setAttribute('updateFormUrlParameters', updateFormUrlParameters);
    var Value = "";

    var Values = $("input[name='integrateFormType']");
    Values.each(function () {
        if ($(this).is(":checked")) {
            Value = $(this).attr("value");
        }
    });
    actExtraParams.setAttribute('integrateFormType', Value);

    var Values = $("input[name='isIntegrateApproveHistory']");
    Values.each(function () {
        if ($(this).is(":checked")) {
            Value = $(this).attr("value");
        }
    });
    actExtraParams.setAttribute('isIntegrateApproveHistory', Value);
    if (Value == "true") {
        var Values = $("input[name='approveHistoryFormSourceType']");
        Values.each(function () {
            if ($(this).is(":checked")){
                Value = $(this).attr("value");
            }
        });
        actExtraParams.setAttribute('approveHistoryFormSourceType', Value);
        if (Value == "false") {
            var approveHistoryFormUrl = $('#approveHistoryFormUrl').val();
            actExtraParams.setAttribute('approveHistoryFormUrl', approveHistoryFormUrl);
        }else{
            actExtraParams.removeAttribute("approveHistoryFormUrl");
        }
    }else{
        actExtraParams.removeAttribute("approveHistoryFormSourceType");
        actExtraParams.removeAttribute("approveHistoryFormUrl");
    }
    var integrateActivities = $('#inqu_status-0-nodeCode').val();
    var integrateActivitiestextField = $('#inqu_status-0-nodeCode_textField').val();
    actExtraParams.setAttribute('integrateActivities', integrateActivities);
    actExtraParams.setAttribute('integrateActivitiestextField', integrateActivitiestextField);

    var nextParticipants = $("input[name='nextParticipant']");
    nextParticipants.each(function () {
        if ($(this).is(":checked")) {
            Value = $(this).attr("value");
        }
    });
    actExtraParams.setAttribute('nextParticipant', Value);
    if(Value=="Post"){
        actExtraParams.setAttribute('nextParticipantPost', $('#nextParticipantPost').val());
    }

    var ifNotifys = $("input[name='ifNotify']");
    ifNotifys.each(function () {
        if ($(this).is(":checked")) {
            Value = $(this).attr("value");
        }
    });
    actExtraParams.setAttribute('ifNotify', Value);

    var disEndProcs = $("input[name='disEndProc']");
    disEndProcs.each(function () {
        if ($(this).is(":checked")) {
            Value = $(this).attr("value");
        }
    });
    actExtraParams.setAttribute('disEndProc', Value);

    var requireOpinionDisEndProcs = $("input[name='requireOpinionDisEndProc']");
    requireOpinionDisEndProcs.each(function () {
        if ($(this).is(":checked")) {
            Value = $(this).attr("value");
        }
    });
    actExtraParams.setAttribute('requireOpinionDisEndProc', Value);

    var requireOpinionBacks = $("input[name='requireOpinionBack']");
    requireOpinionBacks.each(function () {
        if ($(this).is(":checked")) {
            Value = $(this).attr("value");
        }
    });
    actExtraParams.setAttribute('requireOpinionBack', Value);

};

/**
 * 渲染[角色类型+流程组织]输入数据表格
 *
 * @return
 */
ManualActivitySetting.prototype.renderRoleWithOrg = function () {
    var dom = $(this.setting);
    //参与者策略
    var auTactics = $(dom).find('ActivityParticipants');

    function eventsResult(RoleName, RoleDisplayName, DeptType, Dept, DeptVariable, DeptActivity) {
        this.RoleName = RoleName;
        this.RoleDisplayName = RoleDisplayName;
        this.DeptType = DeptType;
        this.Dept = Dept;
        this.DeptVariable = DeptVariable;
        this.DeptActivity = DeptActivity;
    }

    var block = new Array();
    $(dom).find('Participants>Participant').each(function () {
        var row = new eventsResult();
        $(this).find('ParticipantAttribute').each(function () {
            if (this.getAttribute('Name') == 'RoleName') {
                row.RoleName = this.getAttribute('Value');
            }
            if (this.getAttribute('Name') == 'DeptType') {
                row.DeptType = this.getAttribute('Value');
            }
            if (this.getAttribute('Name') == 'Dept') {
                row.Dept = this.getAttribute('Value');
            }
            if (this.getAttribute('Name') == 'DeptVariable') {
                row.DeptVariable = this.getAttribute('Value');
            }
            if (this.getAttribute('Name') == 'DeptActivity') {
                row.DeptActivity = this.getAttribute('Value');
            }
        })
        block.push(row);
    });
    var grid = $("#ef_grid_activityParticipantsResult").data("kendoGrid");
    grid.dataSource.data(block);
}

/**
 * 保存[角色类型+流程组织]输入数据表格
 *
 * @return
 */
ManualActivitySetting.prototype.updateRoleWithOrg = function () {
    // 更新setting
    var doc = this.createXmlDocument();
    var actParts = $(this.setting).find('ActivityParticipants')[0];
    if (actParts == null) {
        actParts = doc.createElement('ActivityParticipants');
        $(this.setting).find('Extras')[0].appendChild(actParts);
    }
    var currentParticipantsExtend = this.getParticipantExtendByLabel("EpassRoleWithInputOrg");
    var participantTypeName = $('Name', $(currentParticipantsExtend)).text();
    var participantDescription = $('Description', $(currentParticipantsExtend)).text();
    var participants = this.getParticipantsByType("EpassRoleWithInputOrg")[0];
    if (participants == null) {
        participants = doc.createElement('Participants');
        participants.setAttribute('ParticipantType', "EpassRoleWithInputOrg");
        participants.setAttribute('ParticipantTypeName', participantTypeName);
        participants.setAttribute('ParticipantDescription', participantDescription);
        $(this.setting).find('ActivityParticipants')[0].appendChild(participants);
    } else
        $(participants).empty();


    var grid = $("#ef_grid_activityParticipantsResult").data("kendoGrid");
    var ractCheckedRows = grid.getDataItems();
    var participant = null;
    if (ractCheckedRows.length > 0)
        for (var i = 0; i < ractCheckedRows.length; i++) {

            var roleName = ractCheckedRows[i]["RoleName"];
            var Dept = ractCheckedRows[i]["Dept"];
            var DeptType = ractCheckedRows[i]["DeptType"];
            var DeptVariable = ractCheckedRows[i]["DeptVariable"];
            var DeptActivity = ractCheckedRows[i]["DeptActivity"];
            if (this.verifyPartHasSelected(roleName, Dept, DeptType, ractCheckedRows, i)) continue;
            participant = doc.createElement('Participant');
            participant.setAttribute('Name', "EpassRoleWithInputOrg_"
                + roleName + "_" + Dept);
            participant.setAttribute('DisplayName', roleName);

            var roleNameNode = doc.createElement('ParticipantAttribute');
            roleNameNode.setAttribute('Name', 'RoleName');
            roleNameNode.setAttribute('Value', roleName);
            participant.appendChild(roleNameNode);

            var DeptNode = doc.createElement('ParticipantAttribute');
            DeptNode.setAttribute('Name', 'Dept');
            DeptNode.setAttribute('Value', Dept);
            participant.appendChild(DeptNode);

            var DeptTypeNode = doc.createElement('ParticipantAttribute');
            DeptTypeNode.setAttribute('Name', 'DeptType');
            DeptTypeNode.setAttribute('Value', DeptType);
            participant.appendChild(DeptTypeNode);

            var DeptNameNode = doc.createElement('ParticipantAttribute');
            DeptNameNode.setAttribute('Name', 'DeptVariable');
            DeptNameNode.setAttribute('Value', DeptVariable);
            participant.appendChild(DeptNameNode);

            var DeptActivityNode = doc.createElement('ParticipantAttribute');
            DeptActivityNode.setAttribute('Name', 'DeptActivity');
            DeptActivityNode.setAttribute('Value', DeptActivity);
            participant.appendChild(DeptActivityNode);

            participants.appendChild(participant);
        }
};

ManualActivitySetting.prototype.getParticipantsByType = function (participantLabel) {
    var participants = $('ActivityParticipants>Participants', $(this.setting));
    var parts = [];
    participants.each(function () {
        if (this.getAttribute("ParticipantType") == participantLabel) parts.push(this);
    });
    return parts;
};

ManualActivitySetting.prototype.getParticipantExtendByLabel = function (participantLabel) {
    var participantExtend = $(DomHelper.parseXml(this.getParticipantExtendSetXml()))
        .find('ParticipantExtend>Label:contains("' + participantLabel
            + '")').parent()[0];
    return participantExtend;
};

ManualActivitySetting.prototype.getParticipantExtendSetXml = function () {
    var participantExtendSetXml = null;
    info = new EiInfo();
    EiCommunicator.send('EWPE00', 'getParticipantExtend', info, {
        onSuccess: function (outInfo) {
            participantExtendSetXml = outInfo.get("ParticipantExtend");
        },
        onFail: function (message) {

        }
    }, false, false);
    return participantExtendSetXml != null ? participantExtendSetXml :
        '<?xml version="1.0" encoding="utf-8"?><ParticipantExtends/>';
};

ManualActivitySetting.prototype.verifyPartHasSelected = function (partId, Dept, DeptType, ractCheckedRows, j) {
    var verifyPartHasSelected = false;
    if (ractCheckedRows.length > 0)
        for (var i = 0; i < j; i++) {
            if (ractCheckedRows[i]["RoleName"] == partId && ractCheckedRows[i]["Dept"] == Dept && ractCheckedRows[i]["DeptType"] == DeptType) {
                verifyPartHasSelected = true;
                break;
            }
        }
    return verifyPartHasSelected;
};

ManualActivitySetting.prototype.renderListBox = function () {
    var activities = this.getAllActivities();
    var allData = [], dataA = [], dataB = [];

    var curActivityName = this.setting.getAttribute("Name");

    $(activities).each(function () {
        var row = {};
        row.Name = this.value.getAttribute("Name");
        row.DisplayName = this.value.getAttribute("Name")+"-"+this.value.getAttribute("DisplayName");
        allData.push(row);
    });
    var row = {};
    row.Name = "PROCESSDEF";
    row.DisplayName = "PROCESSDEF-流程表单";
    allData.push(row);
    dataA = allData;

    var nodeCode = $("#inqu_status-0-nodeCode").val() || "";
    var nodeCode_textField = $("#inqu_status-0-nodeCode_textField").val() || "";

    if (_.isString(nodeCode)) {
        var list = nodeCode.split(","), selectItem;
        _.each(list, function (id) {
            if (selectItem = _.find(dataA, function (item) {
                    return item.Name === id;
                })) {
                dataA.splice(_.indexOf(dataA, selectItem), 1);
                dataB.push(selectItem);
            }
        })
    }

    $("#listBoxA").kendoListBox({
        connectWith: "listBoxB",
        draggable: true,
        dataSource: {
            data: dataA
        },
        dataTextField: "DisplayName",
        dataValueField: "Name",
        toolbar: {
            tools: [
                "transferTo",
                "transferFrom",
                "transferAllTo",
                "transferAllFrom"
            ]
        }
    });

    $("#listBoxB").kendoListBox({
        dataSource: {
            data: dataB
        },
        draggable: true,
        dataTextField: "DisplayName",
        dataValueField: "Name"
    });

};


ManualActivitySetting.prototype.validate = function () {
    var validateMsg = this.validateExtra();
    validateMsg += this.validateEvent();
    return validateMsg;
};


/**
 * 渲染的时间限制设置页面
 */
ManualActivitySetting.prototype.renderTimeoutSetting = function () {
    var dom = $(this.setting);
    var ts = $(dom).find('TimeoutSetting')[0];
    if (ts == null) return;

    var timeoutSettingInputs = $('#timeoutSettingInputs');
    var timeoutEnable = ts.getAttribute('TimeoutEnable');
    if (timeoutEnable == 'true')
        $('#timeoutEnable', timeoutSettingInputs)[0].checked = true;
    else
        $('#timeoutEnable', timeoutSettingInputs)[0].checked = false;
    $('#timeUnit', timeoutSettingInputs).attr('value',
        ts.getAttribute('TimeUnit'));
    $('#timeoutGap', timeoutSettingInputs).attr('value',
        ts.getAttribute('TimeoutGap'));
    $('#warnGap', timeoutSettingInputs).attr('value',
        ts.getAttribute('WarnGap'));
};

ManualActivitySetting.prototype.updateTimeoutSetting = function () {
    var timeoutSettingInputs = $('#timeoutSettingInputs');
    var timeoutEnable = $('#timeoutEnable', timeoutSettingInputs)[0].checked;
    var timeUnit = $('#timeUnit', timeoutSettingInputs).attr('value');
    var timeoutGap = $('#timeoutGap', timeoutSettingInputs).attr('value');
    var warnGap = $('#warnGap', timeoutSettingInputs).attr('value');

    var doc = this.createXmlDocument();
    var ts = $(this.setting).find('TimeoutSetting')[0];
    if (ts == null) {
        ts = doc.createElement('TimeoutSetting');
        $(this.setting).find('Extras')[0].appendChild(ts);
    }
    if (timeoutEnable)
        ts.setAttribute('TimeoutEnable', 'true');
    else
        ts.setAttribute('TimeoutEnable', 'false');
    ts.setAttribute('TimeUnit', timeUnit);
    ts.setAttribute('TimeoutGap', timeoutGap);
    ts.setAttribute('WarnGap', warnGap);

};


ManualActivitySetting.prototype.renderActivityLastExecutor = function () {

    var GRIDNAME = "activityLastExecutorResult";

    var info = new EiInfo();

    var meta = new EiBlockMeta(GRIDNAME);
    var col1 = new EiColumn('ActivityName');
    col1.pos = 0;
    col1.descName = '节点名称';
    col1.labelProperty = 'ActivityName';
    col1.valueProperty = '节点名称';
    col1.width = '100';

    var col2 = new EiColumn('ActivityDisplayName');
    col2.pos = 1;
    col2.descName = '节点显示显示名称';
    col2.labelProperty = 'ActivityDisplayName';
    col2.valueProperty = '节点显示显示名称';
    col2.width = '200';

    meta.addMeta(col1);
    meta.addMeta(col2);

    var block = new EiBlock(meta);
    info.addBlock(block);

    // 绘制grid
    var activityLastExecutorGrid = this.constructGrid(GRIDNAME, info, "true");
    $(document).ready(function () {
        activityLastExecutorGrid.paint();
    });
    return activityLastExecutorGrid;
};


ManualActivitySetting.prototype.getAllActivities = function () {
    var graph = this.editor.graph;
    var root = null;
    root = graph.getCurrentRoot();
    if (root == null) {
        root = graph.getModel().getRoot();
    }
    var model = graph.getModel();
    var filter = function (cell) {
        var tagName = cell.value.tagName;
        return model.isVertex(cell) && (tagName == 'Start' || tagName == 'Manual');
    }
    var acts = [];

    var rootChilds = model.getChildCells(model.getCell("1"));
    $(rootChilds).each(function () {
        var tagName = this.value.tagName;
        if (model.isVertex(this) && tagName == 'Swimlane') {
            var slChilds = model.filterCells(model.getChildCells(this), filter);
            $(slChilds).each(function () {
                acts.push(this);
            });
        }
        if (model.isVertex(this) && (tagName == 'Manual'))
            acts.push(this);
    });
    return acts;
};


ManualActivitySetting.prototype.validateEvent = function () {
    var grid = $("#ef_grid_extraResult").data("kendoGrid");//整个表格
    var datas = grid.getCheckedRows();//所有选中行
    var errMsg = "";
    if (datas.length > 0) {
        var type, method, methodArr = [];
        for (var i = 0; i < datas.length; i++) {
            if (method == "") errMsg = "事件的触发方法不能为空!\n";
            methodArr.push(type + "-" + method);
        }
        var dupMsg = this.validateDuplicateName(methodArr);
        if (dupMsg != "") errMsg += "存在重复的触发事件:" + dupMsg + "!\n";
    }
    return errMsg;
};








